﻿using CADTool_LinXi;
using HaierCADplug_in.Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace HaierCADplug_in.View
{
    /// <summary>
    /// UserWindow.xaml 的交互逻辑
    /// </summary>
    public partial class UserWindow : Window
    {
        public UserWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 登录按钮实现
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            //获取前端传回的登录信息
            UserData userData = new UserData
            {
                Username = usernameTextBox.Text,
                Password = passwordBox.Password
            };

            //从配置文件中获取该值
            string apiLoginUrl = ConfigurationManager.AppSettings["ApiLoginUrl"];

            HttpHelper httpHelper = new HttpHelper();
            //获取服务端返回的结果
            string Result = await httpHelper.PostAsync(apiLoginUrl, userData);
            if (Result== "登录成功")
            {
                GlobalVariables.UserIsActive = true;
            }
            MessageBox.Show(Result);

            
        }
    }
}
